package simco.framework.gui.swing.comp;

import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ResourceBundle;

import simco.framework.gui.graph.supp.ViewModeType;
import simco.framework.gui.swing.listeners.ToolsActionsListener;
import simco.framework.gui.swing.types.InterfaceActionType;
import simco.framework.gui.utils.Configuration;
import simco.framework.gui.utils.LocalizationUtil;

/**
 * Tato trida reprezentuje panel pro vyber modu zobrazeni
 * grafickych objektu na platne.
 * 
 * Kod teto tridy byl (vygenerovan) v IDE Netbeans.
 * 
 * @author Matej Prokop, mythge@students.zcu.cz
 *
 */
public class ViewModePickerPanel extends javax.swing.JPanel 
{
	/**
	 * Radio button group
	 */
	private javax.swing.ButtonGroup buttonGroup1;
	
	/**
	 * Popisek vyberu modu
	 */
    private javax.swing.JLabel titleLabel;
    
    /**
     * Tlacitko pro vyber minimalniho modu
     */
    private javax.swing.JRadioButton minimalModeBtn;
    
    /**
     * Tlacitko pro vyber standarniho modu
     */
    private javax.swing.JRadioButton standardModeBtn;
    
    /**
     * Tlacitko pro vyber detailniho modu
     */
    private javax.swing.JRadioButton detailModeBtn;
	
    /**
     * CheckBox pro moznost nastaveni, zda bude po 
     * zmene modu proveden relayout grafu
     */
    private javax.swing.JCheckBox jCheckBox1;
    
    /**
     * Bundle s nactenou lokalizaci
     */
    private ResourceBundle locResource;
    
    /**
     * Listener infromovany o zmenach modu zobrazeni
     */
    private ToolsActionsListener toolsListener;
    
    /**
     * Font pro vykreslovani nadpisu
     */
    private final Font titleFont = new Font("Tahoma", Font.BOLD, 11 );
    
    /**
     * Vytvori novy panel pro vyber zobrazovaciho modu.
     * 
     * @param actionListener reference na objekt, obslujici zmenu
     * modu zobrazeni
     */
    public ViewModePickerPanel(ToolsActionsListener actionListener) 
    {
    	this.locResource = LocalizationUtil.getResource(this.getClass().getSimpleName());
    	this.toolsListener = actionListener;
    	
        initComponents();
    }
    
    /**
     * Inicializuje a rozmisti komponenty na panelu
     */
    private void initComponents() 
    {
        buttonGroup1 = new javax.swing.ButtonGroup();
        titleLabel = new javax.swing.JLabel();
        minimalModeBtn = new javax.swing.JRadioButton();
        standardModeBtn = new javax.swing.JRadioButton();
        detailModeBtn = new javax.swing.JRadioButton();
        jCheckBox1 = new javax.swing.JCheckBox();

        titleLabel.setFont(titleFont); // NOI18N
        titleLabel.setText(locResource.getString("jLabel1.text")); // NOI18N
        titleLabel.setName("jLabel1"); // NOI18N

        buttonGroup1.add(minimalModeBtn);        
        minimalModeBtn.setText(locResource.getString("minimalModeBtn.text")); // NOI18N
        minimalModeBtn.setToolTipText(locResource.getString("minimalModeBtn.toolTipText")); // NOI18N
        minimalModeBtn.setActionCommand(InterfaceActionType.MINIMAL_MODE.toString()); // NOI18N
        minimalModeBtn.setName("minimalModeBtn"); // NOI18N
        minimalModeBtn.addActionListener(toolsListener);

        buttonGroup1.add(standardModeBtn);
        standardModeBtn.setText(locResource.getString("standardModeBtn.text")); // NOI18N
        standardModeBtn.setToolTipText(locResource.getString("standardModeBtn.toolTipText")); // NOI18N
        standardModeBtn.setActionCommand(InterfaceActionType.STANDARD_MODE.toString()); // NOI18N
        standardModeBtn.setName("standardModeBtn"); // NOI18N
        standardModeBtn.setOpaque(false);
        standardModeBtn.addActionListener(toolsListener);
        
        buttonGroup1.add(detailModeBtn);
        detailModeBtn.setText(locResource.getString("detailModeBtn.text")); // NOI18N
        detailModeBtn.setToolTipText(locResource.getString("detailModeBtn.toolTipText")); // NOI18N
        detailModeBtn.setActionCommand(InterfaceActionType.DETAIL_MODE.toString()); // NOI18N
        detailModeBtn.setName("detailModeBtn"); // NOI18N
        detailModeBtn.addActionListener(toolsListener);

        if(Configuration.getViewMode() == ViewModeType.MINIMAL)
        {
        	minimalModeBtn.setSelected(true);
        }
        else if(Configuration.getViewMode() == ViewModeType.STANDARD)
        {

            standardModeBtn.setSelected(true);
        }
        else
        {

        	detailModeBtn.setSelected(true);
        }
        
        jCheckBox1.setText(locResource.getString("executeReLayoutBox.text")); // NOI18N
        jCheckBox1.setToolTipText(locResource.getString("executeReLayoutBox.toolTipText")); // NOI18N
        jCheckBox1.setName("executeReLayoutBox"); // NOI18N
        jCheckBox1.setSelected(Configuration.isReloAViewModeChange());
        jCheckBox1.addItemListener(
        	    new ItemListener() 
        	    {
        	        public void itemStateChanged(ItemEvent e) 
        	        {
        	            Configuration.setReloAViewModeChange(e.getStateChange() == ItemEvent.SELECTED);
        	        }
        	    }
        	);

        
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titleLabel)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(standardModeBtn)
                            .addComponent(minimalModeBtn)
                            .addComponent(detailModeBtn)))
                        .addComponent(jCheckBox1))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titleLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(minimalModeBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(standardModeBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(detailModeBtn)
                .addGap(18, 18, 18)
                .addComponent(jCheckBox1)
                .addContainerGap(31, Short.MAX_VALUE))
        );

    }
    
}